const path = require('path')

module.exports = {
  chainWebpack: config => {
    // 清除默认svg规则
    config.module.rules.delete('svg')

    // 添加svg-sprite-loader
    config.module
        .rule('svg-sprite')
        .test(/\.svg$/)
        .include
        .add(path.resolve('src/assets/icons/svg'))
        .end()
        .use('svg-sprite-loader')
        .loader('svg-sprite-loader')
        .options({
          symbolId: 'icon-[name]'
        })
  }
}